package com.lavender.transaction.controller;

import com.lavender.transaction.entity.User;
import com.lavender.transaction.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/user")
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    // http://localhost:8081/user/test
    @GetMapping("test")
    public String test() {
        userService.deleteAll();
        User user = new User();
        user.setUserId("admin");
        user.setPassword("123456");
        userService.insert(user);
        User user1 = userService.selectByUserId(user);
        System.out.println("user1:" + user1);
        user.setPassword("567890");
        userService.updateByUserId(user);
        User user2 = userService.selectByUserId(user);
        System.out.println("user2:" + user2);
        userService.deleteByUserId(user);
        User user3 = userService.selectByUserId(user);
        System.out.println("user3:" + user3);
        return "ok";
    }

}
